//
//  CommentTableViewCell.m
//  MovieAppforProject1
//
//  Created by ios on 15/7/23.
//  Copyright (c) 2015年 ios. All rights reserved.
//

#import "CommentTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "UIViewExt.h"

@implementation CommentTableViewCell

- (void)awakeFromNib {
    // Initialization code
}
- (void)setCommentModel:(CommentModel *)commentModel
{
    _commentModel = commentModel;
    [self setNeedsLayout];

}

- (void)layoutSubviews
{
    _contentLabel.numberOfLines = 0;
    _contentLabel.text = _commentModel.content;
    
    _nickNameLabel.text = _commentModel.nickname;
    [_headPotritImageView sd_setImageWithURL:[NSURL URLWithString:_commentModel.userImage]];
    _ratingLabel.text = _commentModel.rating;
    
    
    NSInteger ch;
    UIFont *font = [UIFont systemFontOfSize:15];//11 一定要跟label的显示字体大小一致
    //设置字体
    CGSize size = CGSizeMake(210, 20000.0f);
    NSDictionary * tdic = [NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName,nil];
    size =[_commentModel.content boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:tdic context:nil].size;
    ch = size.height;
    
    _contentLabel.frame = CGRectMake(116, 30, 210, ch+20);
    
    CGRect frame = self.frame;
    frame.size = CGSizeMake(375, ch +90);
    self.frame = frame;

    
    NSLog(@"%@",_contentLabel.text);
    NSLog(@"%f",_contentLabel.frame.size.height);
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
